//聚学院-首页
function jxy_i() {
    let mockData = Mock.mock({
        "bannerlist": [{
            "picUrl": "@image('1920x360',#FFC0CB)",
            "href": "#",
        }, {
            "picUrl": "@image('1920x360',#dFC0aB)",
            "href": "#",
        }, {
            "picUrl": "@image('1920x360',#aFCdCB)",
            "href": "#",
        }],
    });
    new Vue({
        el: "#jxy_i",
        data() {
            return {
                test: 'wst',
                zixunlist: [],
                toutiaolist: [],
                quanzilist: [],
                ketanglist: [],
                peixunlist: [],
                luntan: [],
                advimg: '',
                bannerlist: [],
                advUrl: '',
                loginName: '',
                baomingIndex: '',
                peixunbaomingIndex: '',
                form: {},
                dialogFormVisible: false,
                videoDialogVisible: false,
                formLabelWidth: '120px',
                baomingType: 1, //报名类型 1,培训  2.峰会
                videoUrl: ''
            }
        },
        methods: {
            getData() {
                this.loginName = urlParam.loginName();
                let url = urlParam.domain() + "/api/college/information/index";
                if (urlParam.token() != null) {
                    url += "?token=" + urlParam.token();
                }
                let that = this;
                axios.get(url).then(function(r) {
                    that.luntan = r.data.data.fenghui;
                    that.zixunlist = r.data.data.hangyezixun;
                    that.toutiaolist = r.data.data.xueyuantoutiao;
                    that.quanzilist = r.data.data.quanzi;
                    that.ketanglist = r.data.data.zaixianketang;
                    that.peixunlist = r.data.data.xianxiapeixun;
                })

                //获取广告
                axios.get(urlParam.domain() + '/api/advert/list', {
                    params: {
                        position: urlParam.jxueyPosition()
                    }
                }).then(function(response) {
                    if (response.data.data != undefined) {
                        that.bannerlist = response.data.data;
                        that.advimg = response.data.data[0].picUrl;
                        that.advUrl = response.data.data[0].link;
                    }
                });
            },
            join: function(url) {
                this.videoDialogVisible = true;
                this.videoUrl = url;
            },
            qubaoming: function(index) {
                this.baomingType = 2;
                let that = this;
                this.baomingIndex = index;
                this.form = {};
                this.form.id = this.luntan[index].id;
                if (urlParam.loginName() == '') {
                    this.$message({
                        message: '登录之后才可以报名哦',
                        type: 'warning'
                    });
                    return;
                }
                if (this.luntan[index].beApplied) {
                    this.form.token = urlParam.token();
                    axios({
                        method: 'post',
                        url: urlParam.domain() + "/api/college/summitMeeting/apply",
                        params: this.form
                    }).then(function(r) {
                        that.luntan[index].beApplied = false;
                        that.$message({
                            message: '取消成功',
                            type: 'success'
                        });
                    }).catch(function(error) {
                        that.$message({
                            message: '服务器忙,请稍后再试',
                            type: 'warning'
                        });
                    });
                } else {
                    this.dialogFormVisible = true;
                }
            },
            baoming: function() {
                let that = this;
                this.dialogFormVisible = false;
                this.form.token = urlParam.token();
                let url = "";
                if (this.baomingType == 2) {
                    url = urlParam.domain() + "/api/college/summitMeeting/apply"
                } else {
                    url = urlParam.domain() + "/api/college/train/apply"
                }
                axios({
                    method: 'post',
                    url: url,
                    params: this.form
                }).then(function(r) {
                    if (that.baomingType == 2) {
                        that.luntan[that.baomingIndex].beApplied = !that.luntan[that.baomingIndex].beApplied
                    } else {
                        that.peixunlist[that.peixunbaomingIndex].beApplied = !that.peixunlist[that.peixunbaomingIndex].beApplied
                    }
                    that.$message({
                        message: '报名成功',
                        type: 'success'
                    });
                }).catch(function(error) {
                    that.$message({
                        message: '登录之后才可以报名哦',
                        type: 'warning'
                    });
                });
            },
            peixunbaoming: function(index) {
                this.baomingType = 1;
                let that = this;
                this.peixunbaomingIndex = index;
                this.form = {};
                this.form.id = this.peixunlist[index].id;
                if (urlParam.loginName() == '') {
                    this.$message({
                        message: '登录之后才可以报名哦',
                        type: 'warning'
                    });
                    return;
                }
                if (this.peixunlist[index].beApplied) {
                    this.form.token = urlParam.token();
                    axios({
                        method: 'post',
                        url: urlParam.domain() + "/api/college/train/apply",
                        params: this.form
                    }).then(function(r) {
                        that.peixunlist[that.peixunbaomingIndex].beApplied = false;
                        that.$message({
                            message: '取消成功',
                            type: 'success'
                        });
                    }).catch(function(error) {
                        that.$message({
                            message: '服务器忙,请稍后再试',
                            type: 'warning'
                        });
                    });
                } else {
                    this.dialogFormVisible = true;
                }
            }
        },
        created() {
            this.getData();
        },
        components: {
            'common-swiper': common_swiper,
            'jxy-biaoti': jxy_i_biaoti,
            'base-pro-list': base_pro_list,
            'zixun-list': jxy_zixun_list,
            'quanzi-list': jxy_quanzi_list,
            'ketang-list': jxy_ketang_list,
            'peixun-list': jxy_peixun_list
        }
    });
}

//聚学院-首页-标题组件
let jxy_i_biaoti = {
    props: ['title', 'url'],
    template: `<div class="jxy-biaoti">
        <span class="name">{{title}}</span>
        <a :href="url" class="more">更多></a>
    </div>`
}

//聚学院-首页-资讯列表
let jxy_zixun_list = {
    props: ['list'],
    template: `<div class="jxy-zixun-list">
        <div class="zixun-item" v-for="item,index in list" v-if="index<3">
            <a :href="'zixun_detail.html?'+item.id">
                <img v-for="pic,index in item.picUrl" v-if="index<1" :src="pic.fileUrl">
                <div class="zixun-bottom">
                    <p class="title">{{item.title}}</p>
                    <p class="date">{{item.createTime1}}</p>
                </div>
            </a>
        </div>
    </div>`
}

//聚学院-首页-热门圈子
let jxy_quanzi_list = {
    props: ['list'],
    template: `<div class="jxy-zixun-list">
        <div class="zixun-item" v-for="item,index in list" v-if="index<3">
            <a href="">
                <img v-for="pic,index in item.picUrl" :src="pic.fileUrl" v-if="index<1">
                <div class="zixun-bottom">
                    <p class="name">{{item.title}}</p>                
                </div>
            </a>
        </div>
    </div>`
}

//聚学院-首页-线上课堂
let jxy_ketang_list = {
    props: ['list'],
    template: `<div class="jxy-ketang-list">
        <div class="ketang-item" v-for="item,index in list" v-if="index<3">
            <img :src="item.picUrl">
            <div class="ketang-bottom">
                <p class="title">{{item.title}}</p>
                <p class="date">{{item.endTime}}</p>
                <a href="javascript:void(0)" @click="join(item.videoUrl)" class="goto">进入课堂</a>
            </div>
        </div>
    </div>`,
    methods: {
        join: function(val) {
            this.$emit('callback', val)
        }
    }
}

//聚学院-首页-线下培训
let jxy_peixun_list = {
    props: ['list'],
    template: `<div class="jxy-peixun-list">
        <div class="peixun-item" v-for="item,index in list" v-if="index<4">
            <img :src="item.picUrl">
            <div class="peixun-bottom">
                <p class="title">{{item.title}}</p>
                <p class="address">{{item.area}}</p>
                <p class="date">{{item.endTime}}</p>
                <a href="javascript:void(0)" @click="baoming(index)" v-if="!item.beApplied" class="baoming">报名</a>
                <a href="javascript:void(0)" @click="baoming(index)" v-if="item.beApplied" class="baoming">取消报名</a>
            </div>
        </div>
    </div>`,
    methods: {
        baoming: function(index) {
            this.$emit('callback', index)
        }
    }
}

//聚学院-峰会
function jxy_fenghui() {
    let mockData = Mock.mock({
        'list|6': [{
            'picUrl': '@image(380x310, #FFC0CB)',
            'title': '@ctitle(5, 10)',
            'address': '南京国展中心',
            'startTime': '2017/10/12 9:00-12:00',
            'endTime': '2017/10/12 9:00-12:00',
            'content': '@ctitle(90, 100)',
        }],
        'crumblist': [{
            'href': '',
            'text': '首页'
        }, {
            'href': '',
            'text': '聚学院'
        }, {
            'href': '',
            'text': '峰会'
        }]
    });
    new Vue({
        el: "#jxy_fenghui",
        data() {
            return {
                bannerlist: null,
                list: [],
                total: 0,
                pageNo: 1,
                dialogFormVisible: false,
                form: {},
                formLabelWidth: '120px',
                baomingIndex: ''
            }
        },
        methods: {
            getData() {
                let that = this;
                //获取数据
                this.getList(1);
                //获取广告
                axios.get(urlParam.domain() + '/api/advert/list', {
                    params: {
                        position: urlParam.jxueyuanFenghuiBanner()
                    }
                }).then(function(response) {
                    if (response.data.code == 1) {
                        if (response.data.data != undefined) {
                            that.bannerlist = response.data.data;
                            console.log("获取banner");
                            that.advimg = response.data.data[0].picUrl;
                            that.advUrl = response.data.data[0].link;
                        }
                    }
                });
                this.crumblist = mockData.crumblist;
            },
            getList: function(pageNo) {
                this.pageNo = pageNo;
                let that = this;
                axios.get(urlParam.domain() + "/api/college/summitMeeting/list", {
                    params: {
                        token: urlParam.token(),
                        pageNo: pageNo,
                        pageSize: 10,
                    }
                }).then(function(r) {
                    that.list = r.data.data.list;
                    if (r.data.data.total < 10) {
                        that.total = 1;
                    } else {
                        that.total = r.data.data.total % 10 == 0 ? parseInt(r.data.data.total / 10) : parseInt(r.data.data.total / 10) + 1
                    }
                })
            },
            getPage(page) {
                this.getList(page);
            },
            qubaoming: function(index) {
                let that = this;
                this.baomingIndex = index;
                this.form = {};
                this.form.id = this.list[index].id;
                if (urlParam.loginName() == '') {
                    this.$message({
                        message: '登录之后才可以报名哦',
                        type: 'warning'
                    });
                    return;
                }
                if (this.list[index].beApplied) {
                    this.form.token = urlParam.token();
                    axios({
                        method: 'post',
                        url: urlParam.domain() + "/api/college/summitMeeting/apply",
                        params: this.form
                    }).then(function(r) {
                        that.list[index].beApplied = false;
                        that.$message({
                            message: '取消成功',
                            type: 'success'
                        });
                    }).catch(function(error) {
                        that.$message({
                            message: '服务器忙,请稍后再试',
                            type: 'warning'
                        });
                    });
                } else {
                    this.dialogFormVisible = true;
                }
            },
            baoming: function() {
                let that = this;
                this.dialogFormVisible = false;
                this.form.token = urlParam.token();
                axios({
                    method: 'post',
                    url: urlParam.domain() + "/api/college/summitMeeting/apply",
                    params: this.form
                }).then(function(r) {
                    that.list[that.baomingIndex].beApplied = !that.list[that.baomingIndex].beApplied;
                    that.$message({
                        message: '报名成功',
                        type: 'success'
                    });
                }).catch(function(error) {
                    that.$message({
                        message: '登录之后才可以报名哦',
                        type: 'warning'
                    });
                });
            }
        },
        created() {
            this.getData();
        },
        components: {
            'common-swiper': common_swiper,
            'base-list': jyihui_base_list,
        }
    });
}

//聚学院-行业资讯
function jxy_zixun() {
    let mockData = Mock.mock({
        'list|3': [{
            'img': '@image(240x165, #FFC0CB)',
            'toux': '@image(24x24, #FFC0CB)',
            'title': '@ctitle(10, 15)',
            'desc': '@ctitle(30, 55)',
            'date': '2017-10-12',
            'view|500-800': 500
        }],
        'advimg': {
            'img1': '@image(900x540, #FFC0CB)',
            'img2': '@image(280x260, #FFC0CB)',
            'img3': '@image(280x260, #FFC0CB)',
        }
    });
    new Vue({
        el: "#jxy_zixun",
        data() {
            return {
                crumblist: [{
                    'href': '',
                    'text': '首页'
                }, {
                    'href': '',
                    'text': '聚学院'
                }, {
                    'href': '',
                    'text': '行业资讯'
                }],
                zixuntype: 1,
                list: [],
                total: 0,
                pageNo: 1,
                loginName: '',
                bannerlist: []
            }
        },
        methods: {
            getData() {
                // 'img': '@image(240x165, #FFC0CB)',
                //     'toux': '@image(24x24, #FFC0CB)',
                //     'title': '@ctitle(10, 15)',
                //     'desc': '@ctitle(30, 55)',
                //     'date': '2017-10-12',
                //     'view|500-800': 500
                let category = window.location.href.split("?")[1]
                this.zixuntype = category;
                if (this.zixuntype == 2) {
                    this.crumblist[2].text = '学院头条'
                }
                this.loginName = urlParam.loginName();
                this.getInformation(category, 1);
                let that = this;
                //获取广告
                axios.get(urlParam.domain() + '/api/advert/list', {
                    params: {
                        position: urlParam.jxueyuanZixunPosition()
                    }
                }).then(function(response) {
                    if (response.data.data != undefined) {
                        that.bannerlist = response.data.data;
                    }
                });
                //this.bannerlist = mockData.bannerlist;
                this.advimg = mockData.advimg;
            },
            getInformation: function(categoryId, pageNo) {
                this.pageNo = pageNo;
                let that = this;
                axios.get(urlParam.domain() + "/api/college/information/getPageList", {
                    params: {
                        categoryId: categoryId,
                        pageNo: pageNo,
                        pageSize: 10,
                    }
                }).then(function(r) {
                    that.list = r.data.data.list;
                    if (r.data.data.total < 10) {
                        that.total = 1;
                    } else {
                        that.total = r.data.data.total % 10 == 0 ? parseInt(r.data.data.total) / 10 : parseInt(r.data.data.total) / 10 + 1
                    }
                })
            },
            changeType(val) {
                this.zixuntype = val;
                this.getInformation(val, 1);
            },
            getPage(page) {
                this.getInformation(this.zixuntype, page);
            }
        },
        created() {
            this.getData();
        },
        filters: {
            subcontent: function(value) {
                if (!value) return ''
                if (value.length > 10) {
                    return value.substr(0, 11) + '...';
                }
                return value;
            }
        }
    });
}

//聚学院-行业资讯-资讯详情
function jxy_zixun_detail() {
    new Vue({
        el: "#jxy_zixun_detail",
        data() {
            return {
                loginName: '',
                detailId: 0,
                article: {},
                crumblist: [{
                    'href': '../index/index1.html',
                    'text': '首页'
                }, {
                    'href': 'i.html',
                    'text': '聚学院'
                }, {
                    'href': 'zixun.html',
                    'text': '行业资讯'
                }, {
                    'href': '',
                    'text': ''
                }],
                mysay: '',
                commentList: [],
                showMore: true
            }
        },
        methods: {
            getData() {
                let category = window.location.href.split("?")[1];
                if (category == 2) {
                    this.crumblist[2].text = '学院头条';
                }
                this.loginName = urlParam.loginName();
                let that = this;
                this.detailId = window.location.href.split("?")[1];
                axios.get(urlParam.domain() + "/api/college/information/detail?id=" + this.detailId).then(function(r) {
                    that.article = r.data.data;
                    that.crumblist[3].text = that.article.title;
                    that.commentList = that.article.commentList.slice(0, 10);
                    that.showMore = that.article.commentList.length > 10;
                })
            },
            showMoreComment() {
                this.commentList = this.article.commentList;
                this.showMore = false;
            },
            commitPinlun() {
                if (this.mysay == '') {
                    this.$message({
                        message: '请输入评论内容',
                        type: 'warning'
                    });
                    return
                }
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + "/api/college/information/comment",
                    params: {
                        id: this.detailId,
                        token: urlParam.token(),
                        commentContent: this.mysay
                    }
                }).then(function(r) {
                    that.$message({
                        message: '评论成功',
                        type: 'success'
                    });
                    that.article.commentList.push({ content: that.mysay });
                }).catch(function(error) {
                    that.$message({
                        message: '请先登录',
                        type: 'warning'
                    });
                });
            },
            dianzan() {
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + "/api/college/information/like",
                    params: {
                        id: this.detailId,
                        token: urlParam.token()
                    }
                }).then(function(r) {
                    if (that.article.beLiked) {
                        that.$message({
                            message: '取消成功',
                            type: 'success'
                        });
                        that.article.likeNumber--;
                    } else {
                        that.$message({
                            message: '点赞成功',
                            type: 'success'
                        });
                        that.article.likeNumber++;
                    }
                    that.article.beLiked = !that.article.beLiked;
                }).catch(function(error) {
                    that.$message({
                        message: '请先登录',
                        type: 'warning'
                    });
                });
            },
            shouc() {
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + "/api/college/information/collecting",
                    params: {
                        id: this.detailId,
                        token: urlParam.token()
                    }
                }).then(function(r) {
                    if (that.article.beCollected) {
                        that.$message({
                            message: '取消成功',
                            type: 'success'
                        });
                    } else {
                        that.$message({
                            message: '收藏成功',
                            type: 'success'
                        });
                    }
                    that.article.beCollected = !that.article.beCollected;
                }).catch(function(error) {
                    that.$message({
                        message: '请先登录',
                        type: 'warning'
                    });
                });
            }
        },
        created() {
            this.getData();
        },
        components: {
            'base-article': base_article
        }
    });
}

/* 聚学苑 - 通知 */
function notice(params) {
    new Vue({
        el: '#jxy_notice',
        data() {
            return {
                showDeleteMenu: -1,
                notice_data: [{
                        title: '服装设计简单易学？',
                        name: '李正乐',
                        address: '南京博物馆',
                        date: '2017/11/18 13:20-15:10',
                        con: '展荣制衣厂，一直以来都是以品质求发展的企业发展观，为东莞广州深圳珠海等珠三角地区的现代化企业提供一流工衣厂服工作展荣制衣厂，一直以来都是以品质求发展的企业发展观，为东莞广州深圳珠海等珠三角地区的现代化企业提供一流工衣厂服工作'
                    },
                    {
                        title: '服装设计简单易学？',
                        name: '李正乐',
                        address: '南京博物馆',
                        date: '2017/11/18 13:20-15:10',
                        con: '展荣制衣厂，一直以来都是以品质求发展的企业发展观，为东莞广州深圳珠海等珠三角地区的现代化企业提供一流工衣厂服工作展荣制衣厂，一直以来都是以品质求发展的企业发展观，为东莞广州深圳珠海等珠三角地区的现代化企业提供一流工衣厂服工作'
                    },
                ],
                crumblist: [{
                    'href': '../index/index1.html',
                    'text': '首页'
                }, {
                    'href': 'i.html',
                    'text': '聚学院'
                }, {
                    'href': '',
                    'text': '报告通知'
                }],
            }
        },
        methods: {
            clearAll: function() {
                this.notice_data.splice(0, this.notice_data.length);
            },
            delete_notice: function(e, index) {
                window.event ? window.event.cancelBubble = true : e.stopPropagation();
                // this.showDeleteMenu = index;
                let con = e.currentTarget.nextElementSibling;

                // console.log(e.target.className == 'el-button el-button--default' )

                if (e.currentTarget.tagName == 'I' && con.className == 'el-button el-button--default' || e.target == con) {
                    this.showDeleteMenu = index;

                } else {
                    this.showDeleteMenu = -1;
                }
            },
            remove_notice: function name(index) {
                this.notice_data.splice(index, 1);
            }
        },
        mounted() {
            document.addEventListener('click', this.delete_notice)
        },
        destroyed() {
            document.removeEventListener('click', this.delete_notice)
        }
    })
}

/* 聚学院 热门圈子 */

function circle(params) {
    new Vue({
        el: '#jxy_circle',
        data() {
            return {
                activeName: 'first',
                crumblist: [{
                    'href': '../index/index1.html',
                    'text': '首页'
                }, {
                    'href': 'i.html',
                    'text': '聚学院'
                }, {
                    'href': '',
                    'text': '热门圈子'
                }],
                circleList: [], //圈子list
                invitationList: [], //帖子list
                publishList: [], //我的发布list
                page: {
                    pageNo: 1,
                    pageSize: 10
                },
                user: {
                    picImg: '',
                    username: '',
                    myInvitationCount: 0
                },
                circleList: [], //圈子list
                invitationList: [], //帖子list
                page: {
                    pageNo: 1,
                    pageSize: 10
                },
                invitationPage: {
                    pageNo: 1,
                    pageSize: 10
                }
            }
        },
        methods: {
            handleClick(tab) {
                if (tab.name == 'second') {
                    this.getInvitationData(1, null);
                }
                if (tab.name == 'third') {
                    if (globalAPI.readCookie("token") == '') {
                        this.invitationList = [];
                        this.invitationPage.pageNo = 1;
                        this.invitationPage.total = 0;
                        this.$message({ message: '请先登录', type: 'warning' });
                    } else {
                        this.getInvitationData(1, 1);
                    }
                }
            },
            listen: function(index) {
                this.getData(index)
            },
            invitationListen(index) {
                this.getInvitationData(index, null)
            },
            myInvitationListen(index) {
                this.getInvitationData(index, 1)
            },
            getData(pageNo) {
                let that = this;
                axios({
                    method: "get",
                    url: urlParam.domain() + "/api/college/circle/list",
                    params: {
                        pageNo: pageNo,
                        pageSize: this.page.pageSize,
                    },
                    headers: { "token": urlParam.token() }
                }).then(function(res) {
                    that.circleList = res.data.data.list;
                    that.page.total = getPageCount(res.data.data.total, that.page.pageSize);
                })
            },
            getInvitationData(pageNo, createBy) {
                let that = this;
                axios({
                    method: "get",
                    url: urlParam.domain() + "/api/college/invitation/list",
                    params: {
                        pageNo: pageNo,
                        pageSize: this.invitationPage.pageSize,
                        createBy: createBy
                    },
                    headers: { "token": urlParam.token() }
                }).then(function(res) {
                    that.invitationList = res.data.data.list;
                    that.invitationPage.total = getPageCount(res.data.data.total, that.invitationPage.pageSize);
                })
            },
            circleLike(id, index) {
                let that = this;
                if (globalAPI.readCookie("token") == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                } else {
                    axios({
                        method: "post",
                        url: urlParam.domain() + "/api/college/circle/like?id=" + id,
                        headers: { "token": urlParam.token() }
                    }).then(function(res) {
                        if (that.circleList[index].beLiked) {
                            that.circleList[index].likeNumber--;
                            that.$message({ message: '取消成功', type: 'success' });
                        } else {
                            that.circleList[index].likeNumber++;
                            that.$message({ message: '点赞成功', type: 'success' });
                        }
                        that.circleList[index].beLiked = !that.circleList[index].beLiked
                    }).catch(function(error) {
                        that.$message({ message: '请先登录', type: 'warning' });
                    })
                }
            },
            invitationLike(id, index) {
                let that = this;
                if (globalAPI.readCookie("token") == '') {
                    this.$message({ message: '请先登录', type: 'warning' });
                } else {
                    axios({
                        method: "post",
                        url: urlParam.domain() + "/api/college/invitation/like?id=" + id,
                        headers: { "token": urlParam.token() }
                    }).then(function(res) {
                        if (that.invitationList[index].beLiked) {
                            that.invitationList[index].likeNumber--;
                            that.$message({ message: '取消成功', type: 'success' });
                        } else {
                            that.invitationList[index].likeNumber++;
                            that.$message({ message: '点赞成功', type: 'success' });
                        }
                        that.invitationList[index].beLiked = !that.invitationList[index].beLiked
                    }).catch(function(error) {
                        that.$message({ message: '请先登录', type: 'warning' });
                    })
                }
            },
            getUserInfo() {
                let that = this;
                axios({
                    method: "get",
                    url: urlParam.domain() + "/api/college/circle/getUserInfo",
                    headers: { "token": urlParam.token() }
                }).then(function(res) {
                    that.user.picImg = res.data.data.picImg;
                    that.user.username = res.data.data.username;
                    that.user.myInvitationCount = res.data.data.myInvitationCount;
                })
            }
        },
        created() {
            this.getData(1);
            this.getUserInfo();
        }
    })
}
/* 聚学院 线上培训 */

function online() {
    new Vue({
        el: '#jxy_online',
        data() {
            return {
                activeName: 'first',
                onlineList: [],
                bannerlist: [],
                adList: [],
                offlineList: [],
                crumblist: [{
                    'href': '../index/index1.html',
                    'text': '首页'
                }, {
                    'href': 'i.html',
                    'text': '聚学院'
                }, {
                    'href': '',
                    'text': '线上课堂'
                }],
                type: 1, //1.线上课堂 2.线下培训
                xianshangPage: {
                    pageNo: 1,
                    pageSize: 12
                },
                xianxiaPage: {
                    pageNo: 1,
                    pageSize: 12
                },
                videoDialogVisible: false,
                videoUrl: ''
            }
        },
        methods: {
            xianshanglisten: function(index) {
                this.getData(index, 1);
            },
            xianxialisten: function(index) {
                this.getData(index, 2);
            },
            getData: function(pageNo, categoryId) {
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/college/train/list',
                    responseType: 'stream',
                    params: {
                        pageNo: pageNo,
                        pageSize: this.xianshangPage.pageSize,
                        categoryId: categoryId,
                        token: urlParam.token()
                    },
                }).then(function(response) {
                    if (categoryId == 1) {
                        that.onlineList = response.data.data.list;
                        that.xianshangPage.total = getPageCount(response.data.data.total, that.xianshangPage.pageSize);
                    } else {
                        that.offlineList = response.data.data.list;
                        that.xianxiaPage.total = getPageCount(response.data.data.total, that.xianxiaPage.pageSize);
                    }
                });
            },
            join: function(url) {
                this.videoDialogVisible = true;
                this.videoUrl = url;
            },
            changType: function(tab) {
                if (tab.name == 'first') {
                    this.type = 1;
                    this.crumblist[2].text = "线上课堂";
                    this.getData(1, 1);
                } else {
                    this.type = 2;
                    this.crumblist[2].text = "线下培训";
                    this.getData(1, 2)
                }
            }
        },
        created() {
            this.type = location.href.split("?")[1];
            this.activeName = this.type == 1 ? "first" : "second";
            this.crumblist[2].text = this.type == 1 ? "线上课堂" : "线下培训";
            this.getData(1, this.type);
            let that = this;
            //获取广告
            axios.get(urlParam.domain() + '/api/advert/list', {
                params: {
                    position: urlParam.jxueyuanKetangPosition()
                }
            }).then(function(response) {
                if (response.data.data != undefined) {
                    that.bannerlist = response.data.data;
                }
            });

            //获取广告
            axios.get(urlParam.domain() + '/api/advert/list', {
                params: {
                    position: urlParam.jxueyuanKetangAd()
                }
            }).then(function(response) {
                if (response.data.data != undefined) {
                    that.adList = response.data.data;
                }
            });
        },
        components: {
            'common-swiper': common_swiper,
        }
    })
}

/* 发帖 */
function card() {
    new Vue({
        el: '#jxy_card',
        data() {
            return {
                card_form: {},
                logoUrl: {
                    base64: [""], // base64码
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                }
            }
        },
        methods: {
            onSubmit() {
                let that = this;
                this.card_form.urls = this.logoUrl.url;
                axios({
                    method: 'post',
                    url: urlParam.domain() + "/api/college/invitation/add",
                    data: this.card_form,
                    transformRequest: [function(data) {
                        let ret = ''
                        for (let it in data) {
                            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                        }
                        return ret
                    }],
                    headers: {
                        "token": urlParam.token(),
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                }).then(function(res) {
                    that.$message({ message: '发布成功', type: 'success' });
                })
            }
        },
    })
}